package com.dn.designpatterns.prototype;

/**
 * @program: designpatterns
 * @description: 浅克隆
 * @author: DN
 * @create: 2021-03-28 16:57
 **/
public class PrototypeTest {
    public static void main(String[] args) throws CloneNotSupportedException {
        Realizetype obj1 = new Realizetype();
        Realizetype obj2 = (Realizetype) obj1.clone();
        System.out.println("obj1==obj2?"+(obj1 == obj2));
    }
}

// 具体原型类
class Realizetype implements Cloneable {
    Realizetype() {
        System.out.println("具体原型创建成功!");
    }

    public Object clone() throws CloneNotSupportedException {
        System.out.println("具体原型复制成功!");
        return (Realizetype)super.clone();
    }
}